package test;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.HashMap;
import java.util.Map;

public class Sender {
    public static void main(String[] args) {
        // 1.创建spring容器
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/spring-rabbitmq-producter.xml");
        // 2.从容器中获得 rabbit模板对象
        RabbitTemplate rabbitTemplate = context.getBean(RabbitTemplate.class);
        // 3.发消息
        Map<String,String> map = new HashMap<String,String>();
        map.put("name","大佬欧");
        map.put("email","1084387967@qq.com");
        rabbitTemplate.convertAndSend("msg.user",map);
        context.close();
    }
}
